<template>
  <div class="tab-control">
    <div class="tab-control-item"
         v-for="(item,index) in titles"
         :key="index"
         :class="{'tab-control-item-active': currentType === item.type}"
         @click="tabControlItemClick(item.type)">
      <span>{{ item.title }}</span>
    </div>
  </div>
</template>

<script>
export default {
  name: "TabControl",
  props: {
    titles: {
      type: Array,
      default() {
        return [];
      }
    },
    currentType: {
      type: String
    }
  },
  methods: {
    tabControlItemClick(type) {
      this.$emit("tabControlItemClick", type);
    }
  }
}
</script>

<style scoped>
.tab-control {
  display: flex;
  text-align: center;
  padding: 10px 0 13px 0;
  background-color: #fff;
}

.tab-control .tab-control-item {
  flex: 1;
}

.tab-control .tab-control-item span {
  padding: 5px;
}

.tab-control-item-active span {
  color: var(--color-text);
  border-bottom: 2px solid var(--color-high-text);
}
</style>